home *** CD-ROM | disk | FTP | other *** search
- /* Copyright, 1990, Regents of the University of Colorado */
- #include <stdio.h>
- #include <string.h>
- #include <strings.h>
- #include <fcntl.h>
- #include "shell.h"
-
- FILE *outfile;
-
- void entry(phys, entries)
- int phys; /*physical line number in file of last entry*/
- int entries; /*number of entries so far*/
- {
- int count = phys; /*line number of lines looked at*/
- int logical; /*start of segment*/
- char file[FILENAME];
- static char *line;
- do{
- char *name, *q1,*q2;
- line = get_line(0);
- if (*line == '#') {
- logical = strtol(&line[1], &name, 10);
- q1 = strchr(line,'"');
- q2 = strchr(q1+1,'"');
- strncpy(file,q1,(q2-q1)+1);
- file[(q2-q1)+2] = '\0';
- }
- else if(*line != '\0'){
- count++;
- printf("%s",line);
- }
- else eof = TRUE;
- } while (!eof && (*line != '#'));
- if (!eof){
- entry(count, entries+1);
- fprintf(outfile,"%d %d %s\n",count,logical,file);
- }
- else
- fprintf(outfile,"%d\n",entries);
- }
-
-
- int main(argc, argv)
- int argc;
- char *argv[];
- {
- char sourcename[FILENAME];
-
- strcpy(sourcename, argv[1]);
- outfile = fopen(sourcename,"w");
- entry(1,0);
- return(0);
- }
-